<style>
  .fly-none {
    min-height: 50px;
    padding-top: 0;
    line-height: 50px;
  }

  .laypage-main * {
    border: none !important;
  }

  .laypage-main {
    border: none !important;
  }

  .laypage-main .pagination li {
    border: 1px solid #009E94 !important;
    margin: 0 5px 0 5px;
  }
</style>
<div class="fly-panel fly-column">
  <div class="layui-container">
    <ul class="layui-clear">
      <!-- layui-this -->
      <li class="layui-hide-xs {$cateid == 0 ? 'layui-this' : ''}"><a href="{:url('home/index/index')}">全部</a></li>
      {foreach $CateList as $v}
      <li class="layui-hide-xs {$cateid == $v.id ? 'layui-this' : ''}">
        <a href="{:url('home/index/index',['cateid'=>$v['id']])}">
          {$v.name}
        </a>
      </li>
      {/foreach}

      <!-- 用户登入后显示 -->
      {if condition="$Think.cookie.LoginUser"}
      <li class="layui-hide-xs layui-hide-sm layui-show-md-inline-block">
        <a href="{:url('home/user/home',['postStatus'=>0])}">我发表的贴</a>
      </li>
      <li class="layui-hide-xs layui-hide-sm layui-show-md-inline-block">
        <a href="{:url('home/user/home',['postStatus'=>1])}">我收藏的贴</a>
      </li>
      {/if}
    </ul>


    <div class="fly-column-right layui-hide-xs">
      <span class="fly-search"><i class="layui-icon"></i></span>
      {if condition="$Think.cookie.LoginUser"}
      <a href="{:url('/home/post/post/add')}" class="layui-btn">发表新帖</a>
      {/if}
    </div>

    <!-- <div class="layui-hide-sm layui-show-xs-block" style="margin-top: -10px; padding-bottom: 10px; text-align: center;">
      <a href="jie/add.html" class="layui-btn">发表新帖</a>
    </div> -->
  </div>
</div>
<div class="layui-container">
  <div class="layui-row layui-col-space15">
    <div class="layui-col-md8">
      <div class="fly-panel">
        <div class="fly-panel-title fly-filter">
          <a>置顶</a>
          <a href="#signin" class="layui-hide-sm layui-show-xs-block fly-right" id="LAY_goSignin"
            style="color: #FF5722;">去签到</a>
        </div>
        {if condition="$total > 0"}
        <ul class="fly-list">
          {foreach $ToppList as $v}
          <li>
            <a href="{:url('home/user/index',['id'=>$v.userid])}" class="fly-avatar">
              <img src="{$v.user.avatar ? $v.user.avatar : '/static/home/res/images/avatar.jpg'}"
                alt="{$v.user.nickname}">
            </a>
            <h2>
              <a class="layui-badge">动态</a>
              <a href="{:url('home/index/info',['postid'=>$v['id']])}">{$v.title}</a>
            </h2>
            <div class="fly-list-info">
              <a href="{:url('home/user/index',['id'=>$v.userid])}" link>
                <cite>{$v.user.nickname}</cite>
                {if condition="$v.user.auth == '1'"}
                <i class="iconfont icon-renzheng" title="认证信息：XXX"></i>
                {/if}
                <i class="layui-badge fly-badge-vip">VIP{$v.user.vip}</i>
              </a>
              <span>{$v.createtime}</span>

              <span class="fly-list-kiss layui-hide-xs" title="悬赏飞吻"><i class="iconfont icon-kiss"></i>
                积分:{$v.point}</span>

              {if condition="$v.accept"}
              <span class="layui-badge fly-badge-accept layui-hide-xs">已结</span>
              {/if}
              <span class="fly-list-nums">
                <i class="iconfont icon-pinglun1" title="回答"></i> {$v.visit}
              </span>
            </div>
            <div class="fly-list-badge">
              <span class="layui-badge layui-bg-black">置顶</span>
              <span class="layui-badge layui-bg-red">精帖</span>
            </div>
          </li>
          {/foreach}
        </ul>
        {else /}
        <div class="fly-none">暂无数据</div>
        {/if}
      </div>

      <div class="fly-panel" style="margin-bottom: 0;">

        <div class="fly-panel-title fly-filter">
          <a href="{:url('home/index/index',['cateid'=>$cateid])}"
            class="{$accept === '' && $state == '' ? 'layui-this' : ''}">综合</a>
          <span class="fly-mid"></span>

          <a href="{:url('home/index/index',['cateid'=>$cateid,'accept'=>0])}"
            class="{$accept === '0' ? 'layui-this' : ''}">未结</a>
          <span class=" fly-mid"></span>

          <a href="{:url('home/index/index',['cateid'=>$cateid,'accept'=>1])}"
            class="{$accept === '1' ? 'layui-this' : ''}">已结</a>
          <span class=" fly-mid"></span>

          <a href="{:url('home/index/index',['state'=>'2'])}" class="{$state === '2' ? 'layui-this' : ''}">精华</a>
          <span class=" fly-mid"></span>
          <a href="{:url('home/index/index',['state'=>'3'])}" class="{$state === '3' ? 'layui-this' : ''}">热门</a>
        </div>

        <ul class="fly-list">
          {foreach $PostList as $item}
          <li>
            <a href="{:url('home/user/index',['id' => $item.userid])}" class="fly-avatar">
              <img src="{$item.user.avatar ? $item.user.avatar : '/static/home/res/images/avatar.jpg'}"
                alt="{$item.user.nickname}">
            </a>
            <h2>
              <a class="layui-badge">分享</a>
              <a href="{:url('home/index/info',['postid' => $item.id])}">{$item.title}</a>
            </h2>
            <div class="fly-list-info">
              <a href="{:url('home/user/index',['id'=> $item.userid])}" link>
                <cite>{$item.user.nickname}</cite>
                <!--
                <i class="iconfont icon-renzheng" title="认证信息：XXX"></i>
                <i class="layui-badge fly-badge-vip">VIP3</i>
                -->
              </a>
              <span>{$item.createtime}</span>

              <span class="fly-list-kiss layui-hide-xs" title="悬赏飞吻"><i class="iconfont icon-kiss"></i>
                积分:{$item.point}</span>
              {if condition="$item.accept"}
              <span class="layui-badge fly-badge-accept layui-hide-xs">已结</span>
              {/if}
              <span class="fly-list-nums">
                <i class="iconfont icon-pinglun1" title="回答"></i> {$item.comment}
              </span>
            </div>
            <div class="fly-list-badge">
              <!--<span class="layui-badge layui-bg-red">精帖</span>-->
            </div>
          </li>
          {/foreach}
        </ul>
        <div style="text-align: center">
          <div class="laypage-main">
            {$PostList->render()}
          </div>
        </div>

      </div>
    </div>
    <div class="layui-col-md4">

      <div class="fly-panel fly-signin">
        <div class="fly-panel-title">
          签到
          <i class="fly-mid"></i>
          <a href="javascript:;" class="fly-link" id="LAY_signinHelp">说明</a>
          <i class="fly-mid"></i>
          <a href="javascript:;" class="fly-link" id="LAY_signinTop">活跃榜<span class="layui-badge-dot"></span></a>
          {if condition="$SignList"}
          <span class="fly-signin-days">已连续签到<cite>{$SignList.days}</cite>天</span>
          {/if}
        </div>
        <div class="fly-panel-main fly-signin-main">

          <div class="{$Signing ? 'layui-hide' : ''}">
            <!-- 未签到状态 -->
            <button class="layui-btn layui-btn-danger" id="LAY_signin"
              data-userid="{$Think.cookie.LoginUser['id']}">今日签到</button>
            <span>可获得<cite>5</cite>飞吻</span>
          </div>

          <div class="{$Signing ? '' : 'layui-hide'}">
            <!-- 已签到状态 -->
            <button class="layui-btn layui-btn-disabled">今日已签到</button>
            <span>获得了<cite>5</cite>飞吻</span>
          </div>


        </div>
      </div>

      <div class="fly-panel">
        <h3 class="fly-panel-title">本周热议</h3>
        <ul class="fly-panel-main fly-list-static">
          <li>
            <a href="http://fly.layui.com/jie/4281/" target="_blank">layui 的 GitHub 及 Gitee (码云) 仓库，欢迎Star</a>
          </li>
          <li>
            <a href="http://fly.layui.com/jie/5366/" target="_blank">
              layui 常见问题的处理和实用干货集锦
            </a>
          </li>
          <li>
            <a href="http://fly.layui.com/jie/4281/" target="_blank">layui 的 GitHub 及 Gitee (码云) 仓库，欢迎Star</a>
          </li>
          <li>
            <a href="http://fly.layui.com/jie/5366/" target="_blank">
              layui 常见问题的处理和实用干货集锦
            </a>
          </li>
          <li>
            <a href="http://fly.layui.com/jie/4281/" target="_blank">layui 的 GitHub 及 Gitee (码云) 仓库，欢迎Star</a>
          </li>
        </ul>
      </div>

      <div class="fly-panel fly-rank fly-rank-reply" id="LAY_replyRank">
        <h3 class="fly-panel-title">回贴周榜</h3>
        <dl>
          <!--<i class="layui-icon fly-loading">&#xe63d;</i>-->
          <dd>
            <a href="user/home.html">
              <img
                src="https://tva1.sinaimg.cn/crop.0.0.118.118.180/5db11ff4gw1e77d3nqrv8j203b03cweg.jpg"><cite>贤心</cite><i>106次回答</i>
            </a>
          </dd>
          <dd>
            <a href="user/home.html">
              <img
                src="https://tva1.sinaimg.cn/crop.0.0.118.118.180/5db11ff4gw1e77d3nqrv8j203b03cweg.jpg"><cite>贤心</cite><i>106次回答</i>
            </a>
          </dd>
          <dd>
            <a href="user/home.html">
              <img
                src="https://tva1.sinaimg.cn/crop.0.0.118.118.180/5db11ff4gw1e77d3nqrv8j203b03cweg.jpg"><cite>贤心</cite><i>106次回答</i>
            </a>
          </dd>
          <dd>
            <a href="user/home.html">
              <img
                src="https://tva1.sinaimg.cn/crop.0.0.118.118.180/5db11ff4gw1e77d3nqrv8j203b03cweg.jpg"><cite>贤心</cite><i>106次回答</i>
            </a>
          </dd>
          <dd>
            <a href="user/home.html">
              <img
                src="https://tva1.sinaimg.cn/crop.0.0.118.118.180/5db11ff4gw1e77d3nqrv8j203b03cweg.jpg"><cite>贤心</cite><i>106次回答</i>
            </a>
          </dd>
          <dd>
            <a href="user/home.html">
              <img
                src="https://tva1.sinaimg.cn/crop.0.0.118.118.180/5db11ff4gw1e77d3nqrv8j203b03cweg.jpg"><cite>贤心</cite><i>106次回答</i>
            </a>
          </dd>
          <dd>
            <a href="user/home.html">
              <img
                src="https://tva1.sinaimg.cn/crop.0.0.118.118.180/5db11ff4gw1e77d3nqrv8j203b03cweg.jpg"><cite>贤心</cite><i>106次回答</i>
            </a>
          </dd>
          <dd>
            <a href="user/home.html">
              <img
                src="https://tva1.sinaimg.cn/crop.0.0.118.118.180/5db11ff4gw1e77d3nqrv8j203b03cweg.jpg"><cite>贤心</cite><i>106次回答</i>
            </a>
          </dd>
          <dd>
            <a href="user/home.html">
              <img
                src="https://tva1.sinaimg.cn/crop.0.0.118.118.180/5db11ff4gw1e77d3nqrv8j203b03cweg.jpg"><cite>贤心</cite><i>106次回答</i>
            </a>
          </dd>
          <dd>
            <a href="user/home.html">
              <img
                src="https://tva1.sinaimg.cn/crop.0.0.118.118.180/5db11ff4gw1e77d3nqrv8j203b03cweg.jpg"><cite>贤心</cite><i>106次回答</i>
            </a>
          </dd>
          <dd>
            <a href="user/home.html">
              <img
                src="https://tva1.sinaimg.cn/crop.0.0.118.118.180/5db11ff4gw1e77d3nqrv8j203b03cweg.jpg"><cite>贤心</cite><i>106次回答</i>
            </a>
          </dd>
          <dd>
            <a href="user/home.html">
              <img
                src="https://tva1.sinaimg.cn/crop.0.0.118.118.180/5db11ff4gw1e77d3nqrv8j203b03cweg.jpg"><cite>贤心</cite><i>106次回答</i>
            </a>
          </dd>
        </dl>
      </div>

      <div class="fly-panel" style="padding: 20px 0; text-align: center;">
        <img src="/static/home/res/images/weixin.jpg" style="max-width: 100%;" alt="layui">
        <p style="position: relative; color: #666;">微信扫码关注 layui 公众号</p>
      </div>
    </div>
  </div>
</div>

<script>
  layui.use(['layer'], function () {
    $ = layui.jquery;
    var layer = layui.layer;

    $('#LAY_signin').click(function () {
      var userid = $(this).data('userid')
      $.ajax({
        url: `{:url('home/index/signin')}`,
        dataType: 'json',
        type: "post",
        data: `userid=${userid}`,
        success: function (res) {
          if (res.code == 1) {
            layer.msg(res.msg, { icon: 6 }, function () {
              location.reload();
            })
          } else {
            layer.msg(res.msg, { icon: 5 })
          }
        }
      })
    })
  })
</script>